package main

import (
	"fmt"
	// "net/url"

	"gitee.com/kobeyyf/nothing/base/auth/sign"
)

// http://ecs.aliyuncs.com/?Timestamp=2016-02-23T12:46:24Z&Format=XML&AccessKeyId=testid&Action=DescribeRegions&SignatureMethod=HMAC-SHA1&SignatureNonce=3ee8c1b8-83d3-44af-a94f-4e0ad82fd6cf&Version=2014-05-26&SignatureVersion=1.0
func main() {
	accessKeySecret := "testsecret"

	// rawURL := "http://ecs.aliyuncs.com/?Timestamp=2016-02-23T12:46:24Z&Format=XML&AccessKeyId=testid&Action=DescribeRegions&SignatureMethod=HMAC-SHA1&SignatureNonce=3ee8c1b8-83d3-44af-a94f-4e0ad82fd6cf&Version=2014-05-26&SignatureVersion=1.0"
	// urlP, _ := url.Parse(rawURL)
	// params := urlP.Query()

	// signParams := make(map[string]string, len(params))
	// for k, v := range params {
	// 	signParams[k] = v[0]
	// 	fmt.Println(k, v)
	// }

	signParams := make(map[string]string)

	signParams["Format"] = "XML"
	signParams["AccessKeyId"] = "testid"
	signParams["Action"] = "DescribeRegions"
	signParams["SignatureMethod"] = "HMAC-SHA1"
	signParams["SignatureNonce"] = "3ee8c1b8-83d3-44af-a94f-4e0ad82fd6cf"
	signParams["Version"] = "2014-05-26"
	signParams["SignatureVersion"] = "1.0"
	signParams["Timestamp"] = "2016-02-23T12:46:24Z"
	fmt.Println(signParams)

	str := sign.GetSignature(accessKeySecret, "GET", signParams)
	fmt.Println(str)
}
